<?php
$file = $_FILES['img'];
$filesize = getimagesize($file['tmp_name']);
$filename = time(). mt_rand(1000, 9999) . '.jpg';
move_uploaded_file($file['tmp_name'], 'chatstatic/images/chat/' . $filename);

$filepath = 'http://' . $_SERVER['HTTP_HOST'] . '/chatstatic/images/chat/' . $filename;


$data = array('img' => $filepath, 'width' => $filesize[0], 'height' => $filesize[1]);
echo json_encode($data);